
<div>
  <h1><%= @floor.new_record? ? "新建楼层" : "修改楼层 ##{params[:id]}" %></h1>
</div>

<div class="form-body">
  <%= form_for @floor,
    url: (@floor.new_record? ? admin_floors_path : admin_floor_path(@floor)),
    method: (@floor.new_record? ? 'post' : 'put'),
    html: { class: 'form-horizontal' } do |f| %>

    <% unless @floor.errors.blank? %>
      <div class="alert alert-danger">
        <ul class="list-unstyled">
          <% @floor.errors.messages.values.flatten.each do |error| %>
            <li><i class="fa fa-exclamation-circle"></i> <%= error %></li>
          <% end -%>
        </ul>
      </div>
    <% end -%>

    <div class="form-group">
      <label for="name" class="col-sm-2 control-label">楼层名*:</label>
      <div class="col-sm-5">
        <%= f.text_field :title, class: "form-control", id: 'title' %>
      </div>
    </div>
  
    <div class="form-group">
      <label for="name" class="col-sm-2 control-label">分类*:</label>
      <div class="col-sm-5">
        <select name="floor[category_id]">
          <% @categories.each do |cate| %>
            <option value="<%= cate.id %>" <%= 'selected' if @floor.category_id == cate.id %>><%= cate.title %></option>
          <% end %>
        </select>
      </div>
    </div>

     <div class="form-group">
      <label for="name" class="col-sm-2 control-label">挑选产品*:</label>
      <div class="col-sm-8">
        <product-picker :item-id="<%= @floor.new_record? ? 0 : @floor.id %>" :custom-fun="floorsCallback()"></product-picker>
      </div>
    </div>

    <div class="form-group">
      <div class="col-sm-offset-2 col-sm-8">
        <%= f.hidden_field :product_ids, id: 'hidden_product_ids' %>
        <%= f.submit (@floor.new_record? ? "新建楼层" : "编辑楼层"), class: "btn btn-primary" %>
      </div>
    </div>

  <% end -%>
</div>


